package com.testDemo.utils;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.tokenizer.TokenizerEngine;
import cn.hutool.extra.tokenizer.TokenizerUtil;
import cn.hutool.extra.tokenizer.Word;
import cn.hutool.extra.tokenizer.engine.hanlp.HanLPEngine;
import com.hankcs.hanlp.HanLP;
import com.hankcs.hanlp.seg.common.Term;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 简转繁
 */
public class HanlpTest {
    @Test
    public void s2hk(){
        List<String> strings = FileUtil.readLines("C:\\zouren\\workspace\\HKMAC-all\\annuity-notice-service\\notice-service\\src\\main\\resources\\ext_dict\\main2012.dic", "utf-8");
        List<String> collect = strings.stream().map(row -> HanLP.s2hk(row)).collect(Collectors.toList());
        FileUtil.writeLines(collect,"C:\\zouren\\workspace\\HKMAC-all\\annuity-notice-service\\notice-service\\src\\main\\resources\\ext_dict\\main2012HK.dic","utf-8");
    }
    @Test
    public void segment(){
        TokenizerEngine engine = TokenizerUtil.createEngine();

        String message = "香港年金有限公司:闇下已成功预約會面，現確認預約日期及時間2025年02月04日下午15时30分，地點:香港九龍觀塘偉業街180號 Two Harbour Square 19樓·届時請带同香港永久性居民身份證、銀行戶口證明(如銀行存摺或一份最近3個月内的月結單等)及支票(如以支票繳交保費)出席會面如有查詢，請致電客戶服務熱線(852)2512-5000。「有計劃内容，請参閱香港年金公司官方網頁，計劃受條款及細則約束]";
        cn.hutool.extra.tokenizer.Result result = engine.parse(message);
        result.forEach(row-> System.out.println(row));

//        List<Term> segment = HanLP.segment(message);
//        segment.forEach(row-> System.out.println(row));
    }

}
